package mvv.learn.spring.advisor;

import mvv.learn.spring.anno.HelloTheWorld2;
import mvv.learn.spring.utilities.ResResponse;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @author ManhVV1
 */
@Component
@Aspect
public class HelloTheWorldAdvisior {
	
	@Around("@annotation(helloTheWorld)")
	public ResResponse syncMetaAround(ProceedingJoinPoint joinPoint, HelloTheWorld2 helloTheWorld) throws Throwable {
		ResResponse res = null;
		res = (ResResponse) joinPoint.proceed();
		res.setData(String.format("%s say: Hello the %s 2!", helloTheWorld.value(), res.getData()));
		return res;
	}
}
